package com.it2297.renderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.it2297.model.Payment;
import com.it2297.model.UsedItem;

public class PaymentCellRenderer extends JLabel implements TableCellRenderer {

	private Payment payment;

	public PaymentCellRenderer()
	{
		setOpaque(true);
		setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
		setVerticalTextPosition(JLabel.TOP);
		setIconTextGap(10);
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int column)
	{
		payment = (Payment) object;

		switch (column)
		{
			case 0:
				setIcon(new ImageIcon(System.getProperty("user.dir") + "/img/used-item/1.jpeg"));
				setText("<html><strong>" + payment.getStatus() + "</strong><br/>" + payment.getAmount() + "<br/></html>");
				break;
			case 1:
				setIcon(null);
				setText("<html>Bid<br/>Watch</html>");
				break;
		}

		if (row % 2 == 0)
		{
			setBackground(Color.WHITE);
		}
		else
		{
			setBackground(new Color(240, 240, 240));
		}
		setForeground(Color.BLACK);

		return this;
	}

}
